package com.googlecode.guicehibernate.event.def;

import java.util.Date;

import org.hibernate.HibernateException;
import org.hibernate.event.SaveOrUpdateEvent;
import org.hibernate.event.def.DefaultSaveEventListener;

import com.googlecode.guicehibernate.CreatedAt;


public class TimeSettingSaveEventListener extends DefaultSaveEventListener  {

	private static final long serialVersionUID = 5234490513441526878L;
	
	@Override
	public void onSaveOrUpdate(SaveOrUpdateEvent event) throws HibernateException {
		Object object = event.getObject();
		Times.setTime(object, CreatedAt.class, new Date());
		super.onSaveOrUpdate(event);
	}

}
